import org.w3c.dom.ls.LSException;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-01-14
 * Time: 14:15
 */

public class Main {
    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> row = new ArrayList<>();
        row.add(1); //第一行元素为1
        ret.add(row);
        for(int i  = 1; i < numRows; i++) {
            List<Integer> preRow = ret.get(i-1);
            List<Integer> curRow = new ArrayList<>();
            curRow.add(1);
            for(int j = 1; j < i; j++) {
             int x = preRow.get(j)+preRow.get(j-1);
             curRow.add(x);
            }
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }

    public static void main(String[] args) {
        List<List<Integer>> m = generate(5);
        System.out.println(m);
    }
}
